package net.zz.base.validate.plug;

import org.springframework.util.AntPathMatcher;

import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by ZaoSheng on 2015/5/12.
 */
public class CustomVali {
    public static final String  pack = ".{3,}\\.validat\\w{1,3}\\.constraints\\.\\w{2,15}";
    public static boolean eq(Annotation[] annotations) {
        for (Annotation annotation : annotations){
           String name = annotation.annotationType().getCanonicalName();

           if (name.matches(pack))
               return false;
        }
     return  true;
    }

    public static List<Annotation> getCustomAnnotation(Annotation[] annotations, boolean isCustom) {
        List<Annotation> not = new ArrayList<Annotation>();
        List<Annotation> custom = new ArrayList<Annotation>();
        for (Annotation annotation : annotations){
            String name = annotation.annotationType().getCanonicalName();
            Class cls = annotation.annotationType();
            if (name.matches(pack))
            {
                not.add(annotation );
            }else
            {
                custom.add(annotation);
            }
        }
        if (isCustom)
            return  custom;
        return not;

    }

}